package com.piggy.logi.sys.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 运单状态枚举
 */
@Getter
@AllArgsConstructor
public enum WaybillStatusEnum {

    CANCEL(100, "取消", "取消"),

    WAIT_SUBMIT(101, "待提交", "确认提交"),

    SUBMITED(110, "已提交", "调度"),

    SCHEDULED(111, "调度完成", "提货"),

    PICKUPING(120, "提货中","发车"),

//    LOADED(130, "已装车", "待发车"),

    DEPARTURE(140, "已发车", "到达"),

    //IN_TRANSIT(150, "已发车","在途中"),

//    TRANSFER(160, "中转","中转"),

//    SHUTTLE(170, "短驳","短驳"),

    ARRIVAL(180, "到达","签收"),

//    DELIVERY(190, "送货","送货"),

    SIGNATURE(200, "签收", "完成"),

//    RECIPT(210, "回单", "待回款结算"),

//    SETTLEMENT(220, "回款结算", "待完成"),

    COMPLETED(230, "完成", "完成"),

    STATUS_UNKNOWN(-1, "未知状态", "未知状态"),

    ;

    private final int code;

    private final String info;

    private final String nextInfo;

    private final static Map<Integer,WaybillStatusEnum> statusMap = new HashMap<>();

    /**
     * 待发运单状态：待装车、待发车、在途中会在待发运单可见
     */
    /*public static List<Integer> getDispatchList() {
        return Lists.newArrayList(PICKUPING.code, DEPARTURE.code);
    }*/

    /**
     * 删除运单范围：待提货、已取消状态下运单
     */
    public static boolean notDelete(Integer status) {
        return status <= SUBMITED.code;
    }

    public static WaybillStatusEnum get(int code) {
        return Arrays.stream(WaybillStatusEnum.values()).filter(t-> t.getCode()== code).findFirst().orElse(STATUS_UNKNOWN);
    }

}
